package com.atguigu;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
@WebServlet("/servletA")
public class servletA extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //创建cookie
        Cookie cookie1=new Cookie("keya","valuea");
       // cookie1.setMaxAge(60*1);//设置cookie的存活时间，以秒为单位
        cookie1.setPath("/demo06/servletB");
        Cookie cookie2=new Cookie("keyb","valueb");

        //将cookie放入response对象
        resp.addCookie(cookie1);
        resp.addCookie(cookie2);

    }
}